package ${packagePath}.common.ext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@EnableCaching
public class AuthAdapter implements WebMvcConfigurer {
    @Autowired
    private AuthIntercept authIntercept;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加对用户是否登录的拦截器，并添加过滤项、排除项
        registry.addInterceptor(authIntercept)
                // 指定要拦截的请求
                .addPathPatterns("/**")
                // 排除不拦截的请求
                .excludePathPatterns("/style/**", "/js/**", "/images/**", "*.jpg", "*.css", "*.js", "*.eot", "*.svg", "*.ttf", "*.woff", "*.png", "*.gif"
                        ,"/login", "/error"
                <#if swaggerEnable?? && swaggerEnable == 1>
                ,"/swagger-resources/**", "/swagger-ui.html", "/v2/api-docs", "/webjars/**"
                </#if>
        );
    }
}
